/*
 * Lenovo Group
 * Copyright (c) 2015-2016 All Rights Reserved.
 * 
 * Project Name:assign-tracer
 * Create Time: 2016年2月19日 下午9:06:44
 */
package com.lenovo.lmrp.server.assigntracer.domain.workflow;

import java.util.List;

import com.lenovo.lmrp.api.model.entity.ProcessActivityPO;
import com.lenovo.lmrp.api.model.entity.ProcessPO;
import com.lenovo.lmrp.api.model.entity.TicketProcessPO;

/**
 * 
 * @author wujin
 * @version v1.0
 */
public interface IWorkflowRepository {
    
    /**
     * Create ProcessBO according to processID. 
     * ProcessBO encapsulates business logic, depend objects will be set when Repository create it.
     * 
     * @param processID
     * @param withActivity  indicate whether include Activity_Form list
     * @return
     */
    public ProcessBO createProcessBO(String processID, boolean withActivity);
    
    /**
     * Create TicketProcessBO according to ticketid and itsmcode. 
     * Precondition: Only allow one running ticket process exist in system
     * 
     * if not found ticketprocess po will throw TraceableException!!!
     * 
     * @param itsmCode
     * @param ticketID
     * @param withActivity
     * @return
     */
    public TicketProcessBO createTicketProcessBO(String itsmCode, String ticketID, boolean withActivity);
    
    /**
     * Create ticket process instance from process definition. 
     * After invoke this method, process instance has started in process engine
     * 
     * @param processID
     * @param itsmCode
     * @param ticketID
     * @return
     */
    public TicketProcessPO createTicketProcessPO(String processID, String itsmCode, String ticketID);
    
    /**
     * Pesistent Process definition data to DB
     * 
     * @param itsmcode
     * @param process
     */
    public void storeWorkflow(String itsmcode, ProcessPO process);
    
    /**
     * Obtain ticket running process instance. System should guarantee only one active process instance for one ticket
     * 
     * @param itsmCode
     * @param ticketID
     * @return
     */
    public TicketProcessPO getRuningTicketProcess(String itsmCode, String ticketID);
    
    /**
     * load from DB or cache to get one process defined ActivityForm
     * 
     * @return
     */
    public List<ProcessActivityPO> getProcessActivities(String processID);

    /**
     * 
     * @param processID
     * @param itsmCode
     * @param ticketID
     * @return
     */
    public TicketProcessPO saveTicketProcessPO(TicketProcessPO ticketProcessPO);
    
}
